<?
    class Arvore
    {
        private $xml,$caminho,$msg;
        public function __construct($msg)
        {
            $this->msg = $msg;
        }
        public function carrega($caminho)
        {
            $this->xml = new DOMDocument();
            $this->caminho = base64_encode($caminho);
            if (!$this->xml->load($caminho))
            {
                echo "Nao foi possivel abrir o arquivo: $caminho<br>";
                return 1;
            }
        }
        public function imprime_root()
        {
            $results = $this->xml->getelementsbytagname("subject");
?>
<ul>
    <li class="pasta">Computer Algebra System <a href="arv_criar_pasta.php?cat=0&file=<?php echo $this->caminho ?>"><img src="arvore/novofolder.png" alt="Nova pasta" border="0"></a>
        <ul>
<?
            for ($i=0; $i<$results->length; $i++)
            {
?>
            <li class="pasta">
                <a href="arv_altera.php?cat=<?php echo $i ?>&file=<?php echo $this->caminho ?>"><? echo $results->item($i)->getattribute("name") ?></a>
                <a href="arv_create_item.php?cat=<? echo $i ?>&file=<?php echo $this->caminho ?>"><img src="arvore/novofile.png" alt="Novo item" border="0"></a>
                <a href="arv_remover.php?cat=<? echo $i ?>&file=<?php echo $this->caminho ?>" onclick="javascript:return confirm('<?php echo $this->msg->get('Confirma_Excluir_Pasta') ?>')"><img src="arvore/delete.gif" alt="Deletar" width="14" height="14" border="0"></a>

                <ul>
<?
                $items = $results->item($i)->getelementsbytagname("item");
                for ($j=0;$j<$items->length; $j++)
                {
?>
                    <li class="item">
                        <a href="arv_altera.php?cat=<?php echo $i ?>&item=<?php echo $j ?>&file=<?php echo $this->caminho ?>"><? echo $items->item($j)->getattribute("name")?></a>
                        <a href="arv_remover.php?cat=<?php echo $i ?>&item=<? echo $j ?>&file=<?php echo $this->caminho ?>" onClick="javascript:return confirm('<?php echo $this->msg->get('Confirma_Excluir_Item') ?>')"><img src="arvore/delete.gif" alt="Deletar" width="14" height="14" border="0"></a>
                    </li>
<?
                }
?>
                </ul>
            </li>
<?
            }
?>
        </ul>
    </li>
</ul>
<?
        }
    }
?>
